﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Business;
public partial class client_OilReportPage : System.Web.UI.Page
{
    OilReportService or = new OilReportService();
    protected void Page_Load(object sender, EventArgs e)
    {
        string component_id = Request.QueryString["component_id"].ToString();
        setOilReportTable(component_id);
    }
 protected void setOilReportTable(string component_id) 
    {
        DataTable oilReport = or.getOilReportByComponentId(component_id);
        foreach(DataRow r in oilReport.Rows){
            string sample_id = r["sample_id"].ToString();
            string tested_date = r["tested_date"].ToString();
            string status = this.IntToString(r["status"].ToString());
            TableRow tr = new TableRow();
            TableCell tc_sf = new TableCell();
            tc_sf.Text = sample_id;
            TableCell tc_testdate = new TableCell();
            tc_testdate.Text = tested_date;
            TableCell tc_status = new TableCell();
            tc_status.Text = status;
            tr.Cells.Add(tc_sf);
            tr.Cells.Add(tc_testdate);
            tr.Cells.Add(tc_status);
            TableCell tc_link = new TableCell();
            if(r["reportlink"].ToString()!="NULL"){
            tc_link.Text = "<a href='" + "../inbox/"+r["reportlink"].ToString() + "' target=_blank>Download";
            }else{
                tc_link.Text = "N/A";   
            }
            tr.Cells.Add(tc_link);
            resultTable.Rows.Add(tr);
        }

 }
   
         protected string IntToString(string i)
    {
        string sta = "";
        switch(i){
            case "1": sta = "Normal"; break;
            case "2": sta = "Abnormal"; break;
            case "3": sta = "Moderate"; break;
            case "4": sta = "Severe"; break;
        }
        return sta;

    }


        //    DataTable tk = new DataTable();
     //foreach (DataRow r in oilReport.Rows)
        //{
        //    DataRow tableRow = tk.NewRow();
        //    tableRow["Sample No"] = r["sample_id"].ToString();
        //    tableRow["Tested Date"] = r["tested_date"].ToString();

        //    tableRow["Status"] = this.IntToString(r["status"].ToString());

        //    tableRow["Download Link"] = r["reportlink"].ToString();
        //    tk.Rows.Add(tableRow); 
        //}
        //Session["TaskTable"] = tk;
        //BindData();
        
    }

